package com.dwxt.sport.business.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.sport.business.entity.WisdomVenues;
import com.dwxt.sport.business.entity.WisdomVenuesEquipment;
import com.dwxt.sport.business.service.WisdomVenuesService;
import com.dwxt.sport.business.vo.wisdomVenues.InsertOrUpdateWisdomVenuesEquipmentVo;
import com.dwxt.sport.business.vo.wisdomVenues.InsertOrUpdateWisdomVenuesVo;
import com.dwxt.sport.business.vo.wisdomVenues.SelectWisdomVenuesVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 智慧场馆
 *
 * @author Kuang.JiaZhuo
 * @date 2020-07-31 15:25
 */
@RestController
@RequestMapping("/wisdomVenues")
@Api(tags={"智慧场馆相关接口"})
public class WisdomVenuesController {

    @Resource
    WisdomVenuesService wisdomVenuesService;

    @ApiOperation(value = "新增或修改智慧场馆", notes = "新增或修改智慧场馆", response = Integer.class)
    @PostMapping("/back/insertOrUpdateWisdomVenues")
    public BaseResult insertOrUpdateWisdomVenues(InsertOrUpdateWisdomVenuesVo insertOrUpdateVo){
        int result = this.wisdomVenuesService.insertOrUpdateWisdomVenues(insertOrUpdateVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "获取智慧场馆列表", notes = "按条件查询智慧场馆列表(带分页)", response = WisdomVenues.class)
    @PostMapping("/back/selectWisdomVenuesByCriteria")
    public BaseResult selectWisdomVenuesByCriteria(SelectWisdomVenuesVo selectVo){
        PageInfo<WisdomVenues> pageInfo = this.wisdomVenuesService.selectWisdomVenuesByCriteria(selectVo);
        return BaseResult.ok(pageInfo);
    }

    @ApiOperation(value = "删除智慧场馆", notes = "根据ids批量删除智慧场馆", response= Integer.class)
    @PostMapping(value = "/back/deleteWisdomVenuesByIds")
    public BaseResult deleteWisdomVenuesByIds(@ApiParam(value = "要删除的id字符串,以英文逗号隔开", required = true) @RequestParam String ids){
        int result = this.wisdomVenuesService.deleteWisdomVenuesByIds(ids);
        return BaseResult.ok(result);
    }


    /******************************************************************  关联设备  ******************************************************************************/

    @ApiOperation(value = "新增 或 更新【智慧场馆】设备关联", notes = "新增 或 更新【智慧场馆】设备关联", response = Integer.class)
    @PostMapping("/back/insertOrUpdateWisdomVenuesEquipment")
    public BaseResult insertOrUpdateWisdomVenuesEquipment(InsertOrUpdateWisdomVenuesEquipmentVo insertOrUpdateVo){
        int result = this.wisdomVenuesService.insertOrUpdateWisdomVenuesEquipment(insertOrUpdateVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "删除【智慧场馆】设备关联", notes = "根据ids批量删除【智慧场馆】设备关联", response= Integer.class)
    @PostMapping(value = "/back/deleteWisdomVenuesEquipmentByIds")
    public BaseResult deleteWisdomVenuesEquipmentByIds(@ApiParam(value = "要删除的id字符串,以英文逗号隔开", required = true) @RequestParam String ids){
        int result = this.wisdomVenuesService.deleteWisdomVenuesEquipmentByIds(ids);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "查询【智慧场馆】的设备列表", notes = "根据【智慧场馆】的id查询关联设备的列表(带分页)", response= WisdomVenuesEquipment.class)
    @PostMapping(value = "/back/selectWisdomVenuesEquipmentByPage")
    public BaseResult selectWisdomVenuesEquipmentByPage(@ApiParam(value = "智慧场馆关联id", required = true) @RequestParam String id,
                                                        @ApiParam(value = "起始页", required = true) @RequestParam Integer pageNum,
                                                        @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize){
        String WisdomVenuesId = id;
        PageInfo<WisdomVenuesEquipment> pageInfo = this.wisdomVenuesService.selectWisdomVenuesEquipmentByPage(pageNum,pageSize,WisdomVenuesId);
        return BaseResult.ok(pageInfo);
    }
}
